<!--
 * @Author: Zhouxin 2201_75539691@noreply.gitcode.com
 * @Date: 2024-11-20 20:26:55
 * @LastEditors: Zhouxin 2201_75539691@noreply.gitcode.com
 * @LastEditTime: 2024-11-20 20:33:33
 * @FilePath: \2024.11.20-day08-数组与字符串\demo1.html
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 求一数组中的所有数的和和平均值 -->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
        var sum = 0;
        for (var i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        console.log("和：" + sum);
        console.log("平均值为："+(sum/arr.length));

    </script>
</body>

</html>